﻿using Microsoft.AspNetCore.Mvc.Rendering;
using System;
using System.Collections.Generic;
using System.Text;
using SX.Utils;

namespace SX.Web.Framework
{
    public static class ThemesExt
    {
        public static string AdminTheme(this IHtmlHelper html,string url, string defaultTheme = "") {
            return url.Fmt(AdminThemeVal(html, defaultTheme));
        }

        public static string AdminThemeVal(this IHtmlHelper html,  string defaultTheme="")
        {
            if (defaultTheme.IsNullOrEmpty())
            {
                defaultTheme = AdminThemes.THEMELIST[0];
            }
            string theme = html.ViewContext.HttpContext.Request.Cookies["sxtheme"];
            if (theme.IsNullOrEmpty())
            {
                return defaultTheme;
            }
            return theme;
        }
    }
}
